/*
 * @Descripttion: 
 * @version: 
 * @Author: sueRimn
 * @Date: 2025-06-02 23:01:47
 * @LastEditors: sueRimn
 * @LastEditTime: 2025-10-08 16:06:26
 */
#ifndef _COMMUN_H
#define _COMMUN_H

#include "main.h"

#define COMMON_MAX_LEN 256

typedef enum _MESSAGE_CMD
{


    CMD_REPORT_POWER = 0x100,
    CMD_REPORT_DISTANC, 
    CMD_REPORT_ICM_ACC,
    CMD_REPORT_ICM_GYRO,
    CMD_REPORT_SWITCH, 

    CMD_RECV_LED = 0x300,
    CMD_RECV_POWER,
    CMD_RECV_MOTOR, 
    CMD_RECV_MAGENT,
} MESSAGE_CMD;

typedef struct _message_fram
{
    uint8_t aucHead[2];
    uint8_t ucCmd;
    uint8_t ucDataLen;
    uint8_t aucData[COMMON_MAX_LEN];
    uint8_t ucCheckSum;
}message_fram_t;


void framCheck(uint8_t *pucFram, uint8_t ucFramLen);
void messageOperation(void);

void canReportPower(void);
void canReportDistance(void);
void canReportIcmAcc(void);
void canReportIcmGyro(void);
void canReportSwitch(uint8_t ucCmd, uint8_t ucSwitchStat,uint8_t ucFastStopFlag);
void canTxMessagePackInit(void);

void canCtrlMotor(uint8_t ucMotorAddr, uint8_t ucCmd, uint16_t usObject1, uint8_t ucObjcet2, uint8_t *pucData);

void canFramOperationCallback(CAN_RxHeaderTypeDef *pstCanRxHeader,uint8_t *pucCanRxBuf);


#endif